import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots
races_data = pd.read_csv('races.csv')
diverstanding_data = pd.read_csv('driver_standings.csv')
drivers_data = pd.read_csv('drivers.csv')
constructorstanding_data = pd.read_csv('constructor_standings.csv')
constructors_data = pd.read_csv('constructors.csv')
constructor_race_data = pd.read_csv('constructor_results.csv')
data_2011 = races_data.where(races_data['year']==2011).dropna()
data_2011 = data_2011.merge(diverstanding_data,on='raceId').dropna()
data_2011 = data_2011.merge(drivers_data,on='driverId').dropna()
data_2011.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2011 = data_2011.sort_values(['round','position'])
data_2011
| year | round | circuitId | name | points | position | positionText | wins | driverRef | code | forename | surname | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 361 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 25.0 | 1 | 1 | 1 | vettel | VET | Sebastian | Vettel |
| 342 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 18.0 | 2 | 2 | 0 | hamilton | HAM | Lewis | Hamilton |
| 323 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 15.0 | 3 | 3 | 0 | petrov | PET | Vitaly | Petrov |
| 304 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 12.0 | 4 | 4 | 0 | alonso | ALO | Fernando | Alonso |
| 285 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 10.0 | 5 | 5 | 0 | webber | WEB | Mark | Webber |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 132 | 2011.0 | 19.0 | 18.0 | Brazilian Grand Prix | 0.0 | 24 | 24 | 0 | ambrosio | DAM | Jérôme | d'Ambrosio |
| 113 | 2011.0 | 19.0 | 18.0 | Brazilian Grand Prix | 0.0 | 25 | 25 | 0 | glock | GLO | Timo | Glock |
| 451 | 2011.0 | 19.0 | 18.0 | Brazilian Grand Prix | 0.0 | 26 | 26 | 0 | karthikeyan | KAR | Narain | Karthikeyan |
| 475 | 2011.0 | 19.0 | 18.0 | Brazilian Grand Prix | 0.0 | 27 | 27 | 0 | ricciardo | RIC | Daniel | Ricciardo |
| 485 | 2011.0 | 19.0 | 18.0 | Brazilian Grand Prix | 0.0 | 28 | 28 | 0 | chandhok | CHA | Karun | Chandhok |
494 rows × 12 columns
data_teams_2011 = races_data.where(races_data['year']==2011).dropna()
data_teams_2011 = data_teams_2011.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2011 = data_teams_2011.merge(constructors_data,on='constructorId').dropna()
data_teams_2011.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2011 = data_teams_2011.sort_values(['round','position'])
data_teams_2011.head(30)
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 171 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 35.0 | 1 | 1 | 1 | red_bull | Red Bull |
| 152 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 26.0 | 2 | 2 | 0 | mclaren | McLaren |
| 114 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 18.0 | 3 | 3 | 0 | ferrari | Ferrari |
| 133 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 15.0 | 4 | 4 | 0 | renault | Renault |
| 95 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 4.0 | 5 | 5 | 0 | toro_rosso | Toro Rosso |
| 76 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 3.0 | 6 | 6 | 0 | force_india | Force India |
| 57 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 0.0 | 7 | 7 | 0 | lotus_racing | Lotus |
| 38 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 0.0 | 8 | 8 | 0 | virgin | Virgin |
| 19 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 0.0 | 9 | 9 | 0 | williams | Williams |
| 0 | 2011.0 | 1.0 | 1.0 | Australian Grand Prix | 0.0 | 10 | 10 | 0 | mercedes | Mercedes |
| 172 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 72.0 | 1 | 1 | 2 | red_bull | Red Bull |
| 153 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 48.0 | 2 | 2 | 0 | mclaren | McLaren |
| 115 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 36.0 | 3 | 3 | 0 | ferrari | Ferrari |
| 134 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 30.0 | 4 | 4 | 0 | renault | Renault |
| 190 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 6.0 | 5 | 5 | 0 | sauber | Sauber |
| 96 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 4.0 | 6 | 6 | 0 | toro_rosso | Toro Rosso |
| 77 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 4.0 | 7 | 7 | 0 | force_india | Force India |
| 1 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 2.0 | 8 | 8 | 0 | mercedes | Mercedes |
| 58 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 0.0 | 9 | 9 | 0 | lotus_racing | Lotus |
| 39 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 0.0 | 10 | 10 | 0 | virgin | Virgin |
| 20 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 0.0 | 11 | 11 | 0 | williams | Williams |
| 208 | 2011.0 | 2.0 | 2.0 | Malaysian Grand Prix | 0.0 | 12 | 12 | 0 | hrt | HRT |
| 173 | 2011.0 | 3.0 | 17.0 | Chinese Grand Prix | 105.0 | 1 | 1 | 2 | red_bull | Red Bull |
| 154 | 2011.0 | 3.0 | 17.0 | Chinese Grand Prix | 85.0 | 2 | 2 | 1 | mclaren | McLaren |
| 116 | 2011.0 | 3.0 | 17.0 | Chinese Grand Prix | 50.0 | 3 | 3 | 0 | ferrari | Ferrari |
| 135 | 2011.0 | 3.0 | 17.0 | Chinese Grand Prix | 32.0 | 4 | 4 | 0 | renault | Renault |
| 2 | 2011.0 | 3.0 | 17.0 | Chinese Grand Prix | 16.0 | 5 | 5 | 0 | mercedes | Mercedes |
| 191 | 2011.0 | 3.0 | 17.0 | Chinese Grand Prix | 7.0 | 6 | 6 | 0 | sauber | Sauber |
| 97 | 2011.0 | 3.0 | 17.0 | Chinese Grand Prix | 4.0 | 7 | 7 | 0 | toro_rosso | Toro Rosso |
| 78 | 2011.0 | 3.0 | 17.0 | Chinese Grand Prix | 4.0 | 8 | 8 | 0 | force_india | Force India |
#teams_color_2011 = {'Red Bull Racing':dict(color='darkblue'),
# 'McLaren':dict(color='orange'),
# 'Ferrari':dict(color='red'),
# 'Mercedes':dict(color='teal'),
# 'Renault':dict(color='yellow'),
# 'Williams':dict(color='')
# }
#drivers = pd.DataFrame()
constructors = data_teams_2011['name_y'].unique()
drivers = data_2011['code'].unique()
#drivers['color'] = []
fig1 = go.Figure()
fig2 = go.Figure()
for i in drivers:
d = data_2011.where(data_2011['code'] == i).dropna()
fig1.add_trace(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig2.add_trace(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig1.show()
fig2['layout']['yaxis']['autorange'] = "reversed"
fig2.show()
fig3 = go.Figure()
fig4 = go.Figure()
for i in constructors:
d = data_teams_2011.where(data_teams_2011['name_y'] == i).dropna()
fig3.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig4.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig3.show()
fig4['layout']['yaxis']['autorange'] = "reversed"
fig4.show()
data_2012 = races_data.where(races_data['year']==2012).dropna()
data_2012 = data_2012.merge(diverstanding_data,on='raceId').dropna()
data_2012 = data_2012.merge(drivers_data,on='driverId').dropna()
data_2012.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2012 = data_2012.sort_values(['round','position'])
data_2012.head(30)
drivers = data_2012['code'].unique()
fig5 = go.Figure()
fig6 = go.Figure()
for i in drivers:
d = data_2012.where(data_2012['code'] == i).dropna().sort_values(by='round')
fig5.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig6.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig5.show()
fig6['layout']['yaxis']['autorange'] = "reversed"
fig6.show()
data_teams_2012 = races_data.where(races_data['year']==2012).dropna()
data_teams_2012 = data_teams_2012.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2012 = data_teams_2012.merge(constructors_data,on='constructorId').dropna()
data_teams_2012.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2012 = data_teams_2012.sort_values(['round','position'])
constructors = data_teams_2012['name_y'].unique()
data_teams_2012
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 40 | 2012.0 | 1.0 | 1.0 | Australian Grand Prix | 40.0 | 1 | 1 | 1 | mclaren | McLaren |
| 200 | 2012.0 | 1.0 | 1.0 | Australian Grand Prix | 30.0 | 2 | 2 | 0 | red_bull | Red Bull |
| 160 | 2012.0 | 1.0 | 1.0 | Australian Grand Prix | 12.0 | 3 | 3 | 0 | sauber | Sauber |
| 180 | 2012.0 | 1.0 | 1.0 | Australian Grand Prix | 10.0 | 4 | 4 | 0 | ferrari | Ferrari |
| 140 | 2012.0 | 1.0 | 1.0 | Australian Grand Prix | 6.0 | 5 | 5 | 0 | lotus_f1 | Lotus F1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 79 | 2012.0 | 20.0 | 18.0 | Brazilian Grand Prix | 76.0 | 8 | 8 | 1 | williams | Williams |
| 139 | 2012.0 | 20.0 | 18.0 | Brazilian Grand Prix | 26.0 | 9 | 9 | 0 | toro_rosso | Toro Rosso |
| 39 | 2012.0 | 20.0 | 18.0 | Brazilian Grand Prix | 0.0 | 10 | 10 | 0 | caterham | Caterham |
| 19 | 2012.0 | 20.0 | 18.0 | Brazilian Grand Prix | 0.0 | 11 | 11 | 0 | marussia | Marussia |
| 238 | 2012.0 | 20.0 | 18.0 | Brazilian Grand Prix | 0.0 | 12 | 12 | 0 | hrt | HRT |
239 rows × 10 columns
fig7 = go.Figure()
fig8 = go.Figure()
for i in constructors:
d = data_teams_2012.where(data_teams_2012['name_y'] == i).dropna()
fig7.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig8.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig7.show()
fig8['layout']['yaxis']['autorange'] = "reversed"
fig8.show()
data_2013 = races_data.where(races_data['year']==2013).dropna()
data_2013 = data_2013.merge(diverstanding_data,on='raceId').dropna()
data_2013 = data_2013.merge(drivers_data,on='driverId').dropna()
data_2013.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2013 = data_2013.sort_values(['round','position'])
data_2013
drivers = data_2013['code'].unique()
fig9 = go.Figure()
fig10 = go.Figure()
for i in drivers:
d = data_2013.where(data_2013['code'] == i).dropna().sort_values(by='round')
fig9.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig10.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig9.show()
fig10['layout']['yaxis']['autorange'] = "reversed"
fig10.show()
data_teams_2013 = races_data.where(races_data['year']==2013).dropna()
data_teams_2013 = data_teams_2013.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2013 = data_teams_2013.merge(constructors_data,on='constructorId').dropna()
data_teams_2013.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2013 = data_teams_2013.sort_values(['round','position'])
constructors = data_teams_2013['name_y'].unique()
data_teams_2013
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 19 | 2013.0 | 1.0 | 1.0 | Australian Grand Prix | 30.0 | 1 | 1 | 0 | ferrari | Ferrari |
| 0 | 2013.0 | 1.0 | 1.0 | Australian Grand Prix | 26.0 | 2 | 2 | 1 | lotus_f1 | Lotus F1 |
| 38 | 2013.0 | 1.0 | 1.0 | Australian Grand Prix | 23.0 | 3 | 3 | 0 | red_bull | Red Bull |
| 57 | 2013.0 | 1.0 | 1.0 | Australian Grand Prix | 10.0 | 4 | 4 | 0 | mercedes | Mercedes |
| 76 | 2013.0 | 1.0 | 1.0 | Australian Grand Prix | 10.0 | 5 | 5 | 0 | force_india | Force India |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 151 | 2013.0 | 19.0 | 18.0 | Brazilian Grand Prix | 57.0 | 7 | 7 | 0 | sauber | Sauber |
| 132 | 2013.0 | 19.0 | 18.0 | Brazilian Grand Prix | 33.0 | 8 | 8 | 0 | toro_rosso | Toro Rosso |
| 170 | 2013.0 | 19.0 | 18.0 | Brazilian Grand Prix | 5.0 | 9 | 9 | 0 | williams | Williams |
| 189 | 2013.0 | 19.0 | 18.0 | Brazilian Grand Prix | 0.0 | 10 | 10 | 0 | marussia | Marussia |
| 208 | 2013.0 | 19.0 | 18.0 | Brazilian Grand Prix | 0.0 | 11 | 11 | 0 | caterham | Caterham |
209 rows × 10 columns
fig11 = go.Figure()
fig12 = go.Figure()
for i in constructors:
d = data_teams_2013.where(data_teams_2013['name_y'] == i).dropna()
fig11.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig12.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig11.show()
fig12['layout']['yaxis']['autorange'] = "reversed"
fig12.show()
data_2014 = races_data.where(races_data['year']==2014).dropna()
data_2014 = data_2014.merge(diverstanding_data,on='raceId').dropna()
data_2014 = data_2014.merge(drivers_data,on='driverId').dropna()
data_2014.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2014 = data_2014.sort_values(['round','position'])
data_2014
drivers = data_2014['code'].unique()
fig13 = go.Figure()
fig14 = go.Figure()
for i in drivers:
d = data_2014.where(data_2014['code'] == i).dropna().sort_values(by='round')
fig13.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig14.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig13.show()
fig14['layout']['yaxis']['autorange'] = "reversed"
fig14.show()
data_teams_2014 = races_data.where(races_data['year']==2014).dropna()
data_teams_2014 = data_teams_2014.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2014 = data_teams_2014.merge(constructors_data,on='constructorId').dropna()
data_teams_2014.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2014 = data_teams_2014.sort_values(['round','position'])
constructors = data_teams_2014['name_y'].unique()
data_teams_2014
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 171 | 2014.0 | 1.0 | 1.0 | Australian Grand Prix | 33.0 | 1 | 1 | 0 | mclaren | McLaren |
| 190 | 2014.0 | 1.0 | 1.0 | Australian Grand Prix | 25.0 | 2 | 2 | 1 | mercedes | Mercedes |
| 152 | 2014.0 | 1.0 | 1.0 | Australian Grand Prix | 18.0 | 3 | 3 | 0 | ferrari | Ferrari |
| 133 | 2014.0 | 1.0 | 1.0 | Australian Grand Prix | 10.0 | 4 | 4 | 0 | williams | Williams |
| 114 | 2014.0 | 1.0 | 1.0 | Australian Grand Prix | 9.0 | 5 | 5 | 0 | force_india | Force India |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 113 | 2014.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 30.0 | 7 | 7 | 0 | toro_rosso | Toro Rosso |
| 75 | 2014.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 10.0 | 8 | 8 | 0 | lotus_f1 | Lotus F1 |
| 56 | 2014.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 2.0 | 9 | 9 | 0 | marussia | Marussia |
| 94 | 2014.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 0.0 | 10 | 10 | 0 | sauber | Sauber |
| 37 | 2014.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 0.0 | 11 | 11 | 0 | caterham | Caterham |
209 rows × 10 columns
fig15 = go.Figure()
fig16 = go.Figure()
for i in constructors:
d = data_teams_2014.where(data_teams_2014['name_y'] == i).dropna()
fig15.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig16.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig15.show()
fig16['layout']['yaxis']['autorange'] = "reversed"
fig16.show()
data_2015 = races_data.where(races_data['year']==2015).dropna()
data_2015 = data_2015.merge(diverstanding_data,on='raceId').dropna()
data_2015 = data_2015.merge(drivers_data,on='driverId').dropna()
data_2015.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2015 = data_2015.sort_values(['round','position'])
data_2015
drivers = data_2015['code'].unique()
fig17 = go.Figure()
fig18 = go.Figure()
for i in drivers:
d = data_2015.where(data_2015['code'] == i).dropna().sort_values(by='round')
fig17.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig18.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig17.show()
fig18['layout']['yaxis']['autorange'] = "reversed"
fig18.show()
data_teams_2015 = races_data.where(races_data['year']==2015).dropna()
data_teams_2015 = data_teams_2015.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2015 = data_teams_2015.merge(constructors_data,on='constructorId').dropna()
data_teams_2015.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2015 = data_teams_2015.sort_values(['round','position'])
constructors = data_teams_2015['name_y'].unique()
data_teams_2015
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 5 | 2015.0 | 1.0 | 1.0 | Australian Grand Prix | 43.0 | 1 | 1 | 1 | mercedes | Mercedes |
| 24 | 2015.0 | 1.0 | 1.0 | Australian Grand Prix | 15.0 | 2 | 2 | 0 | ferrari | Ferrari |
| 62 | 2015.0 | 1.0 | 1.0 | Australian Grand Prix | 14.0 | 3 | 3 | 0 | sauber | Sauber |
| 43 | 2015.0 | 1.0 | 1.0 | Australian Grand Prix | 12.0 | 4 | 4 | 0 | williams | Williams |
| 81 | 2015.0 | 1.0 | 1.0 | Australian Grand Prix | 8.0 | 5 | 5 | 0 | red_bull | Red Bull |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 170 | 2015.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 78.0 | 6 | 6 | 0 | lotus_f1 | Lotus F1 |
| 132 | 2015.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 67.0 | 7 | 7 | 0 | toro_rosso | Toro Rosso |
| 75 | 2015.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 36.0 | 8 | 8 | 0 | sauber | Sauber |
| 151 | 2015.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 27.0 | 9 | 9 | 0 | mclaren | McLaren |
| 188 | 2015.0 | 19.0 | 24.0 | Abu Dhabi Grand Prix | 0.0 | 10 | 10 | 0 | manor | Manor Marussia |
189 rows × 10 columns
fig19 = go.Figure()
fig20 = go.Figure()
for i in constructors:
d = data_teams_2015.where(data_teams_2015['name_y'] == i).dropna()
fig19.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig20.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig19.show()
fig20['layout']['yaxis']['autorange'] = "reversed"
fig20.show()
data_2016 = races_data.where(races_data['year']==2016).dropna()
data_2016 = data_2016.merge(diverstanding_data,on='raceId').dropna()
data_2016 = data_2016.merge(drivers_data,on='driverId').dropna()
data_2016.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2016 = data_2016.sort_values(['round','position'])
data_2016
drivers = data_2016['code'].unique()
fig21 = go.Figure()
fig22 = go.Figure()
for i in drivers:
d = data_2016.where(data_2016['code'] == i).dropna().sort_values(by='round')
fig21.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig22.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig21.show()
fig22['layout']['yaxis']['autorange'] = "reversed"
fig22.show()
data_teams_2016 = races_data.where(races_data['year']==2016).dropna()
data_teams_2016 = data_teams_2016.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2016 = data_teams_2016.merge(constructors_data,on='constructorId').dropna()
data_teams_2016.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2016 = data_teams_2016.sort_values(['round','position'])
constructors = data_teams_2016['name_y'].unique()
data_teams_2016
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 42 | 2016.0 | 1.0 | 1.0 | Australian Grand Prix | 43.0 | 1 | 1 | 1 | mercedes | Mercedes |
| 210 | 2016.0 | 1.0 | 1.0 | Australian Grand Prix | 15.0 | 2 | 2 | 0 | ferrari | Ferrari |
| 168 | 2016.0 | 1.0 | 1.0 | Australian Grand Prix | 14.0 | 3 | 3 | 0 | williams | Williams |
| 189 | 2016.0 | 1.0 | 1.0 | Australian Grand Prix | 12.0 | 4 | 4 | 0 | red_bull | Red Bull |
| 147 | 2016.0 | 1.0 | 1.0 | Australian Grand Prix | 8.0 | 5 | 5 | 0 | haas | Haas F1 Team |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 125 | 2016.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 63.0 | 7 | 7 | 0 | toro_rosso | Toro Rosso |
| 167 | 2016.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 29.0 | 8 | 8 | 0 | haas | Haas F1 Team |
| 104 | 2016.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 8.0 | 9 | 9 | 0 | renault | Renault |
| 20 | 2016.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 2.0 | 10 | 10 | 0 | sauber | Sauber |
| 41 | 2016.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 1.0 | 11 | 11 | 0 | manor | Manor Marussia |
231 rows × 10 columns
fig23 = go.Figure()
fig24 = go.Figure()
for i in constructors:
d = data_teams_2016.where(data_teams_2016['name_y'] == i).dropna()
fig23.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig24.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig23.show()
fig24['layout']['yaxis']['autorange'] = "reversed"
fig24.show()
data_2017 = races_data.where(races_data['year']==2017).dropna()
data_2017 = data_2017.merge(diverstanding_data,on='raceId').dropna()
data_2017 = data_2017.merge(drivers_data,on='driverId').dropna()
data_2017.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2017 = data_2017.sort_values(['round','position'])
data_2017
drivers = data_2017['code'].unique()
fig25 = go.Figure()
fig26 = go.Figure()
for i in drivers:
d = data_2017.where(data_2017['code'] == i).dropna().sort_values(by='round')
fig25.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig26.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig25.show()
fig26['layout']['yaxis']['autorange'] = "reversed"
fig26.show()
data_teams_2017 = races_data.where(races_data['year']==2017).dropna()
data_teams_2017 = data_teams_2017.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2017 = data_teams_2017.merge(constructors_data,on='constructorId').dropna()
data_teams_2017.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2017 = data_teams_2017.sort_values(['round','position'])
constructors = data_teams_2017['name_y'].unique()
data_teams_2017
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2017.0 | 1.0 | 1.0 | Australian Grand Prix | 37.0 | 1 | 1 | 1 | ferrari | Ferrari |
| 20 | 2017.0 | 1.0 | 1.0 | Australian Grand Prix | 33.0 | 2 | 2 | 0 | mercedes | Mercedes |
| 40 | 2017.0 | 1.0 | 1.0 | Australian Grand Prix | 10.0 | 3 | 3 | 0 | red_bull | Red Bull |
| 60 | 2017.0 | 1.0 | 1.0 | Australian Grand Prix | 8.0 | 4 | 4 | 0 | williams | Williams |
| 80 | 2017.0 | 1.0 | 1.0 | Australian Grand Prix | 7.0 | 5 | 5 | 0 | force_india | Force India |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 139 | 2017.0 | 20.0 | 24.0 | Abu Dhabi Grand Prix | 57.0 | 6 | 6 | 0 | renault | Renault |
| 119 | 2017.0 | 20.0 | 24.0 | Abu Dhabi Grand Prix | 53.0 | 7 | 7 | 0 | toro_rosso | Toro Rosso |
| 199 | 2017.0 | 20.0 | 24.0 | Abu Dhabi Grand Prix | 47.0 | 8 | 8 | 0 | haas | Haas F1 Team |
| 179 | 2017.0 | 20.0 | 24.0 | Abu Dhabi Grand Prix | 30.0 | 9 | 9 | 0 | mclaren | McLaren |
| 159 | 2017.0 | 20.0 | 24.0 | Abu Dhabi Grand Prix | 5.0 | 10 | 10 | 0 | sauber | Sauber |
200 rows × 10 columns
fig27 = go.Figure()
fig28 = go.Figure()
for i in constructors:
d = data_teams_2017.where(data_teams_2017['name_y'] == i).dropna()
fig27.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig28.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig27.show()
fig28['layout']['yaxis']['autorange'] = "reversed"
fig28.show()
data_2018 = races_data.where(races_data['year']==2018).dropna()
data_2018 = data_2018.merge(diverstanding_data,on='raceId').dropna()
data_2018 = data_2018.merge(drivers_data,on='driverId').dropna()
data_2018.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2018 = data_2018.sort_values(['round','position'])
data_2018
drivers = data_2018['code'].unique()
fig29 = go.Figure()
fig30 = go.Figure()
for i in drivers:
d = data_2018.where(data_2018['code'] == i).dropna().sort_values(by='round')
fig29.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig30.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig29.show()
fig30['layout']['yaxis']['autorange'] = "reversed"
fig30.show()
data_teams_2018 = races_data.where(races_data['year']==2018).dropna()
data_teams_2018 = data_teams_2018.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2018 = data_teams_2018.merge(constructors_data,on='constructorId').dropna()
data_teams_2018.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2018 = data_teams_2018.sort_values(['round','position'])
constructors = data_teams_2018['name_y'].unique()
data_teams_2018
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2018.0 | 1.0 | 1.0 | Australian Grand Prix | 40.0 | 1 | 1 | 1 | ferrari | Ferrari |
| 21 | 2018.0 | 1.0 | 1.0 | Australian Grand Prix | 22.0 | 2 | 2 | 0 | mercedes | Mercedes |
| 42 | 2018.0 | 1.0 | 1.0 | Australian Grand Prix | 20.0 | 3 | 3 | 0 | red_bull | Red Bull |
| 63 | 2018.0 | 1.0 | 1.0 | Australian Grand Prix | 12.0 | 4 | 4 | 0 | mclaren | McLaren |
| 84 | 2018.0 | 1.0 | 1.0 | Australian Grand Prix | 7.0 | 5 | 5 | 0 | renault | Renault |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 83 | 2018.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 62.0 | 6 | 6 | 0 | mclaren | McLaren |
| 125 | 2018.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 52.0 | 7 | 7 | 0 | force_india | Force India |
| 146 | 2018.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 48.0 | 8 | 8 | 0 | sauber | Sauber |
| 188 | 2018.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 33.0 | 9 | 9 | 0 | toro_rosso | Toro Rosso |
| 167 | 2018.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 7.0 | 10 | 10 | 0 | williams | Williams |
210 rows × 10 columns
fig31 = go.Figure()
fig32 = go.Figure()
for i in constructors:
d = data_teams_2018.where(data_teams_2018['name_y'] == i).dropna()
fig31.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig32.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig31.show()
fig32['layout']['yaxis']['autorange'] = "reversed"
fig32.show()
data_2019 = races_data.where(races_data['year']==2019).dropna()
data_2019 = data_2019.merge(diverstanding_data,on='raceId').dropna()
data_2019 = data_2019.merge(drivers_data,on='driverId').dropna()
data_2019.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2019 = data_2019.sort_values(['round','position'])
data_2019
drivers = data_2019['code'].unique()
fig33 = go.Figure()
fig34 = go.Figure()
for i in drivers:
d = data_2019.where(data_2019['code'] == i).dropna().sort_values(by='round')
fig33.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig34.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig33.show()
fig34['layout']['yaxis']['autorange'] = "reversed"
fig34.show()
data_teams_2019 = races_data.where(races_data['year']==2019).dropna()
data_teams_2019 = data_teams_2019.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2019 = data_teams_2019.merge(constructors_data,on='constructorId').dropna()
data_teams_2019.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2019 = data_teams_2019.sort_values(['round','position'])
constructors = data_teams_2019['name_y'].unique()
data_teams_2019
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 84 | 2019.0 | 1.0 | 1.0 | Australian Grand Prix | 44.0 | 1 | 1 | 1 | mercedes | Mercedes |
| 42 | 2019.0 | 1.0 | 1.0 | Australian Grand Prix | 22.0 | 2 | 2 | 0 | ferrari | Ferrari |
| 63 | 2019.0 | 1.0 | 1.0 | Australian Grand Prix | 15.0 | 3 | 3 | 0 | red_bull | Red Bull |
| 21 | 2019.0 | 1.0 | 1.0 | Australian Grand Prix | 8.0 | 4 | 4 | 0 | haas | Haas F1 Team |
| 0 | 2019.0 | 1.0 | 1.0 | Australian Grand Prix | 6.0 | 5 | 5 | 0 | renault | Renault |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 167 | 2019.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 85.0 | 6 | 6 | 0 | toro_rosso | Toro Rosso |
| 146 | 2019.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 73.0 | 7 | 7 | 0 | racing_point | Racing Point |
| 125 | 2019.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 57.0 | 8 | 8 | 0 | alfa | Alfa Romeo |
| 41 | 2019.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 28.0 | 9 | 9 | 0 | haas | Haas F1 Team |
| 209 | 2019.0 | 21.0 | 24.0 | Abu Dhabi Grand Prix | 1.0 | 10 | 10 | 0 | williams | Williams |
210 rows × 10 columns
fig35 = go.Figure()
fig36 = go.Figure()
for i in constructors:
d = data_teams_2019.where(data_teams_2019['name_y'] == i).dropna()
fig35.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig36.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig35.show()
fig36['layout']['yaxis']['autorange'] = "reversed"
fig36.show()
data_2020 = races_data.where(races_data['year']==2020).dropna()
data_2020 = data_2020.merge(diverstanding_data,on='raceId').dropna()
data_2020 = data_2020.merge(drivers_data,on='driverId').dropna()
data_2020.drop(columns=['date','time','url_x','url_y','driverStandingsId','driverId','dob','number','nationality','raceId'],inplace=True)
data_2020 = data_2020.sort_values(['round','position'])
data_2020
drivers = data_2020['code'].unique()
fig37 = go.Figure()
fig38 = go.Figure()
for i in drivers:
d = data_2020.where(data_2020['code'] == i).dropna().sort_values(by='round')
fig37.add_traces(go.Scatter(x=d['name'],y=d['points'],name=i,mode='lines+markers'))
fig38.add_traces(go.Scatter(x=d['name'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig37.show()
fig38['layout']['yaxis']['autorange'] = "reversed"
fig38.show()
data_teams_2020 = races_data.where(races_data['year']==2020).dropna()
data_teams_2020 = data_teams_2020.merge(constructorstanding_data,on='raceId').dropna()
data_teams_2020 = data_teams_2020.merge(constructors_data,on='constructorId').dropna()
data_teams_2020.drop(columns=['date','time','url_x','url_y','constructorStandingsId','constructorId','nationality','raceId'],inplace=True)
data_teams_2020 = data_teams_2020.sort_values(['round','position'])
constructors = data_teams_2020['name_y'].unique()
data_teams_2020
| year | round | circuitId | name_x | points | position | positionText | wins | constructorRef | name_y | |
|---|---|---|---|---|---|---|---|---|---|---|
| 153 | 2020.0 | 1.0 | 70.0 | Austrian Grand Prix | 37.0 | 1 | 1 | 1 | mercedes | Mercedes |
| 119 | 2020.0 | 1.0 | 70.0 | Austrian Grand Prix | 26.0 | 2 | 2 | 0 | mclaren | McLaren |
| 136 | 2020.0 | 1.0 | 70.0 | Austrian Grand Prix | 19.0 | 3 | 3 | 0 | ferrari | Ferrari |
| 102 | 2020.0 | 1.0 | 70.0 | Austrian Grand Prix | 8.0 | 4 | 4 | 0 | racing_point | Racing Point |
| 85 | 2020.0 | 1.0 | 70.0 | Austrian Grand Prix | 6.0 | 5 | 5 | 0 | alphatauri | AlphaTauri |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 152 | 2020.0 | 17.0 | 24.0 | Abu Dhabi Grand Prix | 131.0 | 6 | 6 | 0 | ferrari | Ferrari |
| 101 | 2020.0 | 17.0 | 24.0 | Abu Dhabi Grand Prix | 107.0 | 7 | 7 | 1 | alphatauri | AlphaTauri |
| 67 | 2020.0 | 17.0 | 24.0 | Abu Dhabi Grand Prix | 8.0 | 8 | 8 | 0 | alfa | Alfa Romeo |
| 16 | 2020.0 | 17.0 | 24.0 | Abu Dhabi Grand Prix | 3.0 | 9 | 9 | 0 | haas | Haas F1 Team |
| 50 | 2020.0 | 17.0 | 24.0 | Abu Dhabi Grand Prix | 0.0 | 10 | 10 | 0 | williams | Williams |
170 rows × 10 columns
fig39 = go.Figure()
fig40 = go.Figure()
for i in constructors:
d = data_teams_2020.where(data_teams_2020['name_y'] == i).dropna()
fig39.add_trace(go.Scatter(x=d['name_x'],y=d['points'],name=i,mode='lines+markers'))
fig40.add_trace(go.Scatter(x=d['name_x'],y=d['position'],name=i,mode='lines+markers',hovertext=d.points))
fig39.show()
fig40['layout']['yaxis']['autorange'] = "reversed"
fig40.show()